<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>&#x9ED8;&#x8BA4;&#x503C; | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>&#x9ED8;&#x8BA4;&#x503C;</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>默认值</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/parsing/defaults/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/01-parsing/17-defaults.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(&quot;15&quot;, &quot;hh&quot;)
</code></pre>

							</div>
<p>&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; moment &#x5BF9;&#x8C61;&#xFF0C;&#x4EC5;&#x6307;&#x5B9A;&#x4E00;&#x4E9B;&#x5355;&#x4F4D;&#xFF0C;&#x5176;&#x4F59;&#x7684;&#x5C06;&#x4F1A;&#x9ED8;&#x8BA4;&#x4E3A;&#x5F53;&#x524D;&#x7684;&#x65E5;&#x671F;&#x3001;&#x6708;&#x4EFD;&#x3001;&#x5E74;&#x4EFD;&#xFF0C;&#x5C0F;&#x65F6;&#x3001;&#x5206;&#x949F;&#x3001;&#x79D2;&#x949F;&#x548C;&#x6BEB;&#x79D2;&#x9ED8;&#x8BA4;&#x4E3A; 0 &#x3002;</p>
<p>&#x5F53;&#x6CA1;&#x4F20;&#x5165;&#x4EFB;&#x4F55;&#x503C;&#x65F6;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x73B0;&#x5728;&#x65F6;&#x95F4;&#xFF1A;</p>
<pre><code class="language-javascript">moment();  // &#x5F53;&#x524D;&#x7684;&#x65E5;&#x671F;&#x548C;&#x65F6;&#x95F4;&#x3002;
</code></pre>
<p>&#x5F53;&#x4EC5;&#x4F20;&#x5165;&#x5C0F;&#x65F6;&#x3001;&#x5206;&#x949F;&#x3001;&#x79D2;&#x949F;&#x548C;&#x6BEB;&#x79D2;&#x65F6;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x4ECA;&#x5929;&#xFF1A;</p>
<pre><code class="language-javascript">moment(5, &quot;HH&quot;);  // &#x4ECA;&#x5929; 5:00:00.000
moment({hour: 5});  // &#x4ECA;&#x5929; 5:00:00.000
moment({hour: 5, minute: 10});  // &#x4ECA;&#x5929; 5:10.00.000
moment({hour: 5, minute: 10, seconds: 20});  // &#x4ECA;&#x5929; 5:10.20.000
moment({hour: 5, minute: 10, seconds: 20, milliseconds: 300});  // &#x4ECA;&#x5929; 5:10.20.300
</code></pre>
<p>&#x5F53;&#x4EC5;&#x4F20;&#x5165;&#x65E5;&#x671F;&#x548C;&#x66F4;&#x5C0F;&#x7684;&#x5355;&#x4F4D;&#x65F6;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;&#x672C;&#x6708;&#x548C;&#x4ECA;&#x5E74;&#xFF1A;</p>
<pre><code class="language-javascript">moment(5, &quot;DD&quot;);  // &#x672C;&#x6708;&#x7684;&#x7B2C; 5 &#x5929;
moment(&quot;4 05:06:07&quot;, &quot;DD hh:mm:ss&quot;);  // &#x672C;&#x6708;&#x7684;&#x7B2C; 4 &#x5929; 05:06:07.000
</code></pre>
<p>&#x5982;&#x679C;&#x672A;&#x6307;&#x5B9A;&#x5E74;&#x4EFD;&#xFF0C;&#x5219;&#x9ED8;&#x8BA4;&#x4E3A;&#x4ECA;&#x5E74;&#xFF1A;</p>
<pre><code class="language-javascript">moment(3, &quot;MM&quot;);  // &#x4ECA;&#x5E74;&#x7B2C;&#x4E09;&#x4E2A;&#x6708;&#xFF08;&#x4E09;&#x6708;&#xFF09;
moment(&quot;Apr 4 05:06:07&quot;, &quot;MMM DD hh:mm:ss&quot;);  // &#x4ECA;&#x5E74;&#x56DB;&#x6708;&#x7684;&#x7B2C; 4 &#x5929; 05:06:07.000
</code></pre>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(&quot;15&quot;, &quot;hh&quot;)
</code></pre>

							</div>
<p>You can create a moment object specifying only some of the units, and the rest
will be defaulted to the current day, month or year, or 0 for hours, minutes,
seconds and milliseconds.</p>
<p>Defaulting to now, when nothing is passed:</p>
<pre><code class="language-javascript">moment();  // current date and time
</code></pre>
<p>Defaulting to today, when only hours, minutes, seconds and milliseconds are passed:</p>
<pre><code class="language-javascript">moment(5, &quot;HH&quot;);  // today, 5:00:00.000
moment({hour: 5});  // today, 5:00:00.000
moment({hour: 5, minute: 10});  // today, 5:10.00.000
moment({hour: 5, minute: 10, seconds: 20});  // today, 5:10.20.000
moment({hour: 5, minute: 10, seconds: 20, milliseconds: 300});  // today, 5:10.20.300
</code></pre>
<p>Defaulting to this month and year, when only days and smaller units are passed:</p>
<pre><code class="language-javascript">moment(5, &quot;DD&quot;);  // this month, 5th day-of-month
moment(&quot;4 05:06:07&quot;, &quot;DD hh:mm:ss&quot;);  // this month, 4th day-of-month, 05:06:07.000
</code></pre>
<p>Defaulting to this year, if year is not specified:</p>
<pre><code class="language-javascript">moment(3, &quot;MM&quot;);  // this year, 3rd month (March)
moment(&quot;Apr 4 05:06:07&quot;, &quot;MMM DD hh:mm:ss&quot;);  // this year, 4th April, 05:06:07.000
</code></pre>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>